<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>

<sec:authentication property="principal" var="currentPrincipal" scope="page" />

<div class="modal-dialog ms-modal-dialog" style="width: 55%" >
  <div class="modal-content" >
     
    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
      <h4 class="modal-title">添加</h4>
    </div>

    <form class="form-horizontal ms-form form-personal-info" method="POST" action="${ctx.host}/coupon-template/create" data-validate="true">

      <div class="modal-body">
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">优惠券名称</label>
          <div class="pull-left" style="width: 30%">
            <input type="text" class="form-control" name="name" data-validate="required" placeholder="请输入优惠券名称"/>
          </div>
          
          <label class="col-xs-2 control-label">折扣类型</label>
          <div class="pull-left" style="width: 30%">
            <input type="text" class="form-control" name="dicountType" data-validate="required" readonly value="固定金额"/>
          <%--  <select name="discountType" class="form-control select2" data-validate="required">
              <option value=""></option>
              <c:forEach var="couponTemplateDiscountType" items="${enums['couponTemplateDiscountType']}" >
                <option value="${couponTemplateDiscountType}">${couponTemplateDiscountType.description}</option>
              </c:forEach>
            </select>--%>
          </div>
        </div>

        
        <div id="fixed_amount" class="form-group ms-form-group ">
          <label class="col-xs-2 control-label">面值</label>
          <div class="pull-left" style="width: 30%">
            <input type="text" class="form-control" name="inputAmount" data-validate="required|float" placeholder="请输入面值" />
          </div>
          
          <label class="col-xs-2 control-label">最低消费金额</label>
          <div class="pull-left" style="width: 30%">
            <input type="text" class="form-control" name="inputMinAmount" data-validate="required|float" placeholder="请输入最低消费金额" />
          </div>
        </div>
        
        <div class="form-group x-form-group">
          <%-- <label class="col-xs-2 control-label">类型</label>
          <div class="pull-left" style="width: 30%">
            <select name="type" class="form-control select2" data-validate="required">
              <option value=""></option>
              <c:forEach var="couponTemplateType" items="${enums['couponTemplateType']}" >
                <option value="${couponTemplateType}">${couponTemplateType.description}</option>
              </c:forEach>
            </select>
          </div> --%>
          
        <%--   <label class="product col-xs-2 control-label hide">产品名称</label>
          <div class="product pull-left hide" style="width: 30%">
            <select name="product.id" class="select2 form-control" data-validate="required">
              <option value=""></option>
              <c:forEach var="product" items="${persist.products}">
                <option value="${product.id}">${product.name}</option>
              </c:forEach>
            </select>
          </div> --%>
          
          <%-- <label class="productType col-xs-2 control-label hide">类别名称</label>
          <div class="productType pull-left hide" style="width: 30%">
            <select name="productType" class="select2 form-control" data-validate="required">
              <option value=""></option>
              <c:forEach var="productType" items="${enums['productType']}">
                <option value="${productType}">${productType.description}</option>
              </c:forEach>
            </select>
          </div> --%>
        </div>
      </div>

      <div class="modal-footer ms-modal-footer">
        <button type="submit" class="btn ms-btn btn-primary">确定</button>
        <button type="button" class="btn ms-btn ms-btn-gary" data-dismiss="modal">取消</button>
      </div>

    </form>

  </div>
</div>
<script>
$(function() {
    
    $('select[name="discountType"]').select2({
      placeholder : '请选择所属折扣类型',
      minimumResultsForSearch : -1,
      allowClear : false
    });
    
    $('select[name="giveAvailable"]').select2({
        placeholder : '请选择是否可转赠',
        minimumResultsForSearch : -1,
        allowClear : false
      });
    
    $('select[name="type"]').select2({
      placeholder : '请选择所属类型',
      minimumResultsForSearch : -1,
      allowClear : false
    });

    
  })

</script>
